package cn.tedu.egmvc1.controller;

import cn.tedu.egmvc1.mapper.AddressMapper;
import cn.tedu.egmvc1.pojo.entity.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/v1/address/")
public class AddressController {
    @Autowired AddressMapper addressMapper;
    @PostMapping (value = "insert")
    public String addAddress(Address address){
        addressMapper.insertAddress(address);
        return "添加成功";
    }
    @GetMapping (value = "select")
    public List<Address> selectAddress (){
        System.out.println(addressMapper.selectAddress());
        return addressMapper.selectAddress();
    }
    @PostMapping(value = "delect")
    public String deleteAddress(int id){
        addressMapper.deleteAddress(id);
        return "删除成功";
    }
    @PostMapping(value = "update")
    public String update(Address address){
        addressMapper.update(address);
        return "修改成功";
    }
}
